package org.zhadoop.stream.cql.semanticanalyzer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.streaming.exception.ErrorCode;

/**
 * 常量的公共方法
 * @author zwd
 *
 */
public class ConstUtils {
	private static final Logger LOG = LoggerFactory.getLogger(ConstUtils.class);
	
	public static Integer formatInt(String number) throws SemanticAnalyzerException{
		try {
			return Integer.valueOf(number);
		} catch (NumberFormatException e) {
			SemanticAnalyzerException exception = 
					new SemanticAnalyzerException(ErrorCode.SEMANTICANALYZE_CONSTANT_FORMAT, number,"INT");
			LOG.error("Faild to format to Int.",exception);
			throw exception;
		}
	}
}
